import { Request } from '@/utils'
import * as URL from './urls'

// 登录
export async function login (data) {
  return Request({
    method: 'post',
    url: URL.LoginUrl,
    data
  })
}

/**
 * 菜单
 */
// 系统菜单列表
export async function fetchMenuList (params) {
  return Request({
    method: 'get',
    url: URL.menuListUrl,
    params
  })
}
// 系统菜单新增
export async function fetchMenuCreate (data) {
  return Request({
    method: 'post',
    url: URL.menuCreateUrl,
    data
  })
}
// 系统菜单更新
export async function fetchMenuUpdate (data) {
  return Request({
    method: 'post',
    url: URL.menuUpdateUrl,
    data
  })
}
// 系统菜单删除
export async function fetchMenuDelete (params) {
  return Request({
    method: 'post',
    url: URL.menuDeleteUrl + '/' + params
  })
}
// 我可见的菜单
export async function fetchMenuNav (params) {
  return Request({
    method: 'get',
    url: URL.menuNavUrl,
    params
  })
}

/**
 * 角色
 */
// 角色列表
export async function fetchRoleList (params) {
  return Request({
    method: 'get',
    url: URL.roleListUrl,
    params
  })
}
// 角色详情
export async function fetchRoleInfo (params) {
  return Request({
    method: 'get',
    url: URL.roleInfoUrl + '/' + params.roleId,
    params: {
      subjectId: params.subjectId
    }
  })
}
// 角色新增
export async function fetchRoleCreate (data) {
  return Request({
    method: 'post',
    url: URL.roleCreateUrl,
    data
  })
}
// 角色修改
export async function fetchRoleUpdate (data) {
  return Request({
    method: 'post',
    url: URL.roleUpdateUrl,
    data
  })
}
// 角色修改
export async function fetchRoleDelete (data) {
  return Request({
    method: 'post',
    url: URL.roleDeleteUrl,
    data
  })
}

/**
 * 项目
 */
// 角色修改
export async function fetchMyProjects (data) {
  return Request({
    method: 'post',
    url: URL.myProjectsUrl,
    data
  })
}
